package algocasts;

public class P55_hammingDistance {
    int numberOfOne(int n) {
        int count = 0;
        while (n != 0) {
            ++count;
            n &= (n - 1);
        }
        return count;
    }

    public int hammingDistance(int x, int y) {
        return numberOfOne(x ^ y);
    }
}
